<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no">  
    <title>订单详情</title>
    <link rel="stylesheet" href="__PUBLIC__/Home/css/memberOrder.css">
    <script>
        var rnumber = Math.floor(Math.random()*1000);
        history.replaceState({mod: rnumber}, 'Title', '?mod='+rnumber);
    </script>
    <include file="Public/common_js"/>
</head>
<body>
	<div class="warp">
        <div id="ycOrderIdTip" class="order-id-tip" style="display:none;">
            对不起！您上传的身份信息有误未通过审核，为保证您能顺利收到商品，请重新上传！
            <a id="ycIdUploadBtn" href="javascript:;" class="go-up">去上传&gt;</a>
        </div>
        <!--订单类别-->
		<div class="member-order-top mgTop">
			<!-- 查看更多物流信息 -->
            <php>$kuaidiurl = get_url()</php>
			<div class="member-logistics-more">
                <if condition="$vt[logi_name] neq '怡臣速送'">
                    <a href="javascript:0" onclick="kuaidi(this)" data-url="https://m.kuaidi100.com/index_all.html?type={$order_data['logi_name']}&postid={$order_data['logi_no']}&callbackurl={$kuaidiurl[top]}{$kuaidiurl[host]}/member/memberOredrData/order_id/{$orderId}" data-id="{$order_data['logi_no']}">
                        <i><img src="__PUBLIC__/Home/images/logistics-icon_a.png" alt=""></i>
                        <h3>点击查看更多物流信息</h3>
                    </a>
                <else />
                    <a href="{:url('Member/delivery',['order_id' => $vo[order_id]])}">
                        <i><img src="__PUBLIC__/Home/images/logistics-icon_a.png" alt=""></i>
                        <h3>点击查看更多物流信息</h3>
                    </a>
                </if>
			</div>
			<div class="member-location-more">
				<a href="">
					<i><img src="__PUBLIC__/Home/images/logistics-icon_b.png" alt=""></i>
					<h3>收货人：<span>{$order_data[ship_name]}</span><span class="location-iphone">{$addr_data[ship_mobile]}</span></h3>
					<h3>收货地址:{$order_data[ship_addr]}</h3>
				</a>
			</div>
		</div>		
		<!-- 订单列表 -->
		<div class="member-order-list mgTop">
			<!--已发货-->
			<div class="member-order-listber">
				<!--商铺名称-->
				<div class="member-order-header">
					<div class="shop-choice">
						<i><img src="__PUBLIC__/Home/images/member-shop-icon.png"></i>
						<span>{$order_data[local_name]}</span>
					</div>
				</div>
				<!--订单详情-->
				<div class="member-order-contant">
					<!--商品描述-->
                    <php>
                        $price = '';
                        $g_price = '';
                         //0-不需要验证身份证；1-上传身份证；2-上传身份证和照片
                        $sfyz_type = 0;
                    </php>
					<div class="single-item dataItem">
                        <foreach name="data" item="vo" key="k" >
                            <div class="swipe-item">
                                <a href="" class="img"><img src="/Uploads/{$vo[s_url]}" alt=""></a>
                                <div class="goods-text">
                                    <a href="" class="name">{$vo[name]}</a>
                                    <p class="pninfo"><span class="price">¥{$vo[price]}</span><span class="num">&nbsp;X&nbsp;{$vo[nums]}</span></p>
                                </div>
                                <!-- 退款成功 -->
                                <php>
                                    switch($vo['t_status']){
                                        case '-1' :
                                        case '0' : echo ""; break;
                                        case '1' :
                                        case '2' :
                                        case '3' :
                                        case '6' :
                                        case '4' : echo "<div class='refund-tips red' >退款中</div>";  break;
                                        case '5' : echo "<div class='refund-tips red'>退款成功</div>"; break;
                                    }
                                </php>
                                <!-- 退款中 -->
                            </div>
                            <php>
                                $price += $vo['price'];
                                $g_price += $vo['g_price'];
                                $tmp = intval($vo['identity_card_status']);
                                if($tmp > $sfyz_type){                                
                                	$sfyz_type = $tmp;
                                }
                            </php>

                        </foreach>
                    <!--商品数量和价格-->
                    <div class="swipe-price">
						<!--<span class="swipe-price_lei red">组合促销</span>-->
                    	<div class="swipe-price-data">
							<span><if condition="$order_data[cost_freight] gt 0 ">(含运费{$order_data[cost_freight]}元)<else /> (不含运费)</if> 共计: <em class="red"> {$order_data[total_amount]}</em></span>
						</div>
					</div>
				</div>
				</div>
			</div>
		</div>
        <php></php>
		<!--订单信息module-->
		<div class="order-mes mgTop">
			<!--商铺名称-->
			<div class="member-order-header">
				<div class="shop-choice">
					<span>订单信息</span>
				</div>
			</div>
			<!--订单详情-->

			<div class="order-mes-list">
					<!--代发货-->
					<p><label>订单状态:</label><span class="order-mes-active">{$order_data[order_msg]}</span></p>
					<!--交易关闭-->
					<p style="display: none"><label>订单状态:</label><span class="order-mes-active">删除订单</span></p>
					<!--待自提-->
					<p style="display: none"><label>订单状态:</label><span class="order-mes-active">待自提</span></p>
					<p><label>订单号码:</label><span>{$order_data[order_id]}</span></p>
					<!--<p><label>订单状态:</label><span>待发货</span></p>-->
					<p><label>下单时间:</label><span>{$order_data[createtime]|date='Y-m-d H:i:s',###} </span></p>
					<p><label>支付方式:</label><span>{$order_data[payment]}</span></p>
					<p><label>订单备注:</label><span>{$order_data[memo]}</span></p>
			</div>
			<!--订单结算结果-->
			<div class="order-balance-module mgTop">
				<p>
					<label>商品总金额：</label>
					<span>￥{$order_data[cost_item]}</span>
				</p>
				<p>
					<label>运费：</label>
					<span>￥{$order_data[cost_freight]?$order_data[cost_freight]:'0'}</span>
				</p>
				<p>
					<label>优惠金额：</label>
					<span>￥<php>echo (($order_data['cost_item']+$order_data['cost_freight'])-$order_data['total_amount'])</php></span>
				</p>
            <if condition="$order_data['bonus_pay'] gt 0">
                <p>
                    <label>使用奖金：</label>
                    <span>￥<php>echo (($order_data['bonus_pay']))</php></span>
                </p>
                <p>
                    <label>微信支付：</label>
                    <span>￥<php>echo ($order_data['total_amount']-$order_data['bonus_pay'])</php></span>
                </p>
            </if>
				<p>
					<label>实付金额：</label>
					<span class="balance-current red">￥{$order_data[total_amount]}</span>
				</p>
			</div>
			<!--订单详情页操作-->

			<div class="member-order-but">
                <if condition="($order_data[status] eq 'finish') and (($order_data[refund_ago_goods_status] eq 2) or ($order_data[refund_ago_money_status] eq 2) )">
                    <!--<a class="refund-but order-but-public current" href="{:url('Member/after_sale_refund',['order_id' => $order_data[order_id]])}">退款详情</a>-->
                    <a class="cancel-but order-but-public current" href="{:url('Member/afterSale',['order_id' => $order_data[order_id]])}">售后</a>
                    <!--已失效-->
                <elseif  condition="$order_data[status] eq 'dead'"/>
                        <a class="cancel-but order-but-public current"  href="javascript:void(0)" onclick="ajaxOpreateOrder('{$order_data[order_id]}',3)">删除订单</a>

                <else />
                    <!--未支付-->
                    <if condition="$order_data[pay_status] eq '0'">
                        <a class="refund-but order-but-public current" href="javascript:0" onclick="ajaxOpreateOrder('{$order_data[order_id]}',1)">取消订单</a>
                        <a class="reminder-but order-but-public current"  href="{:url('Member/payOrder',['order_id' => $order_data[order_id]])}">去付款</a>
                    </if>
                    <!--未发货-->
                    <if condition="($order_data[pay_status] eq '1') and ($order_data[ship_status] eq '0')">
                        <if condition='(($order_data[refund_ago_goods_status] eq 2) or ($order_data[refund_ago_money_status] eq 2) )'>
                            <!--<a class="refund-but order-but-public current" href="{:url('Member/after_sale_refund',['order_id' => $order_data[order_id]])}">退款详情</a>-->
                            <a class="refund-but order-but-public current" href="{:url('Member/afterSale',['order_id' => $order_data[order_id]])}">售后</a>

                        <else />
                            <if condition="$order_data[status] eq 'active'">
                                <a class="refund-but order-but-public current "  href="{:url('MemberRefund/index',['order_id' => $order_data[order_id],'sell' => 'refund_front_status'])}">退款</a>
                                <else/>
                                <a class="cancel-but order-but-public current"  href="{:url('MemberRefund/index',['order_id' => $order_data[order_id],'sell' => 'refund_front_status'])}">退款详情</a>
                            </if>
                        </if>
                        <if condition="$order_data[status] eq 'active'">
                            <a class="reminder-but order-but-public current"  href="javascript:0" onclick="askOrder()">催单</a>
                        </if>
                    </if>
                    <!--已发货 -->
                    <if condition="($order_data[pay_status] eq '1') and ($order_data[ship_status] eq '1') and ($order_data[comment_status] eq '0')">
                        <a class="refund-but order-but-public current" href="{:url('Member/afterSale',['order_id' => $order_data[order_id]])}">售后</a>
                        <a class="reminder-but order-but-public current "  href="javascript:void(0)" onclick="ajaxOpreateOrder('{$order_data[order_id]}',2)">确认收货</a>
                    </if>
                    <!--交易完成未评价、退款完成-->
                    <if condition="($order_data[received_status] eq '1') and ($order_data[comment_status] eq '1')">
                        <a class="refund-but order-but-public current" href="{:url('Member/afterSale',['order_id' => $order_data[order_id]])}">售后</a>
                        <a class="reminder-but order-but-public current "  href="{:url('Member/memberEvaluation',['order_id' => $order_data[order_id]])}">评价</a>
                    </if>
                    <!--交易完成（已评价）-->
                    <if condition="($order_data[received_status] eq '1') and ($order_data[comment_status] eq '2')">
                        <a class="cancel-but order-but-public current" href="{:url('Member/afterSale',['order_id' => $order_data[order_id]])}">售后</a>
                        <!--<a class="refund-but order-but-public current" href="{:url('Member/afterSale',['order_id' => $order_data[order_id]])}">售后</a>
                        <a class="reminder-but order-but-public current "  href="javascript:0">再次购买</a>-->
                    </if>

                </if>

                <!--交易完成(完结)-->
               <!-- <if condition='$order_status[0] eq 11 '>
                    <a class="cancel-but order-but-public current"  href="javascript:0">再次购买</a>
                </if>-->

			</div>
		</div>
    </div>
	<!-- 绑定手机弹窗 -->
	<div class="alert-popup askorder-reminder" style="display: none">
		<p style="display:block;">如果您的订单还没有发货，可以拨打 <span class="tel">{$order_data[tel]}</span>联络发货人。</p>
		<p><a href="javascript:void(0);" class="cancel">取消</a><a href="tel://{$order_data[tel]}" class="confirm">拨打</a></p>
	</div>
	<script>require(['memberOrderData'])</script>
    <script>        
        var _isAjaxProcess = false;
		function askOrder(){
			_global.promote.popup(".askorder-reminder");
		}
        function ajaxOpreateOrder( orderId, stat){
            if(_isAjaxProcess) return;
            var tiShi;
            if(stat == 1){
                tiShi = '是否取消订单？'
            }else if(stat == 2){
                tiShi = '是否确认收货？'
            }else if(stat == 3){
                tiShi = '是否是删除订单？'
            }
            if (confirm(tiShi)) {
                _isAjaxProcess = true;
                _global.promote.loadPopup("正在处理中...");
                $.ajax({
                    type: "POST",
                    url: "{:url('Member/cancelOrder')}",
                    data: { "order_id": orderId ,"stat": stat },
                    dataType: "json",
                    success: function (rs) {
                        _global.promote.removeLoad();
                        _global.promote.alertPopup(rs.msg);
                        if(rs.stat){
                            setTimeout(function(){
                                window.location.reload();
                            },300);
                        }
                        _isAjaxProcess = false;
                    },
                    error: function () {
                        _global.promote.removeLoad();
                        _global.promote.alertPopup('服务器异常，请稍后重试！');
                        _isAjaxProcess = false;
                    }
                });
            }
        }
       /* function cancelOrder(orderId,stat){
            $.post("{:url('Member/cancelOrder')}", { "order_id": orderId ,"stat": stat },
                    function(data){
                        alert(data.msg);
                        window.location.reload();
                    }, "json");
        }*/
        function kuaidi(e){
            if(!$(e).data('id')){
                _global.promote.alertPopup('该订单未发货，不能查看物流信息！');
            }else{
                window.location.href=$(e).data('url');
            }
        }
    </script>
    <php>
    	$isNeedId = false;
        $isValidIDInfo = true;
        //身份证号码
        $curIdNum = $memberData['identity_card_num'];
        //身份证名
        $curIdName = $memberData['identity_name'];
        //身份证照片
        $curIdPhoto = $memberData['identity_photo'];
        /*身份证验证，默认0,验证通过1,验证不过2,申请审核3*/
    	$curIdStatus = intval($memberData['identity_verifi']);
        if((empty($curIdPhoto) && $sfyz_type == 2) || $curIdStatus == 2){
        	$isValidIDInfo = false;
            $isNeedId = true;
        }
        if($isNeedId){
            $sfNeedJs = array('validate' => true, 'upload' => true);
            echo '<script type="text/javascript">';
            echo 'var _ycIdData = {"yzType" : '.$sfyz_type.', "idNum" : "'.$curIdNum.'", "idName" : "'.$curIdName.'", "from" : "order"}';
            echo '</script>';		
    </php>
    <include file="Public/id_validate"/>
    <php> } </php>
</body>
</html>
